#include <iostream>
#include <string>
#include <memory>
class Fruit {
public:
    Fruit() {}
    virtual void show() = 0;
};

class Apple : public Fruit {
public:
    Apple() {}
    void show() {
        std::cout << "我是⼀个苹果" << std::endl;
    }
};

class Banana : public Fruit {
public:
    Banana() {}
    void show() {
        std::cout << "我是⼀个⾹蕉" << std::endl;
    }
};

class FruitFactory {
public:
    static std::shared_ptr<Fruit> create(const std::string& name) {
        if (name == "苹果") {
            return std::make_shared<Apple>();
        }
        else if (name == "⾹蕉") {
            return std::make_shared<Banana>();
        }
        return std::shared_ptr<Fruit>();
    }
};

int main()
{
    std::shared_ptr<Fruit> fruit = FruitFactory::create("苹果");
    fruit->show();

    fruit = FruitFactory::create("⾹蕉");
    fruit->show();
    return 0;
}